iT邦幫忙

2024 iThome 鐵人賽

DAY 11
0

在python程式開發的過程中,通常會裝很多的套件來使用,但這些套件之間可能會有版本相容的問題,所以我們通常會使用虛擬環境來維護專案所需要的套件,這邊簡單介紹conda的環境設定以及語言模型開發會用到的套件安裝:

conda環境設定

到anaconda 首頁下載:https://docs.anaconda.com/miniconda/miniconda-install/
(安裝miniconda會比較輕量)
https://ithelp.ithome.com.tw/upload/images/20240925/20151952pgbWbVi5S1.png
根據OS選擇要下載的安裝包:
https://ithelp.ithome.com.tw/upload/images/20240925/20151952bvj4gGn3vL.png
打開安裝包進行安裝設定:
https://ithelp.ithome.com.tw/upload/images/20240925/20151952w9Obo9E2k3.png
https://ithelp.ithome.com.tw/upload/images/20240925/201519524f2blyKwBB.png
https://ithelp.ithome.com.tw/upload/images/20240925/20151952qruLZHTB6w.png
https://ithelp.ithome.com.tw/upload/images/20240925/20151952TU61pbpzgc.png
https://ithelp.ithome.com.tw/upload/images/20240925/20151952clmf11PXPM.png
等進度條跑完就安裝完成了!
https://ithelp.ithome.com.tw/upload/images/20240925/20151952fzHXar1XZX.png
https://ithelp.ithome.com.tw/upload/images/20240925/20151952jGVGvxXiPv.png

載完之後使用下列指定到終端機建立一個python的虛擬環境:

## Input:
conda create --name iTH-GenAI-Chaos python==3.10
## Output:
Channels:
 - defaults
Platform: osx-arm64
Collecting package metadata (repodata.json): done
Solving environment: done

## Package Plan ##

  environment location: /opt/miniconda3/envs/iTH-GenAI-Chaos

  added / updated specs:
    - python==3.10


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    pip-24.2                   |  py310hca03da5_0         2.3 MB
    python-3.10.0              |       hbdb9e5c_5        12.6 MB
    setuptools-72.1.0          |  py310hca03da5_0         2.4 MB
    wheel-0.43.0               |  py310hca03da5_0         108 KB
    ------------------------------------------------------------
                                           Total:        17.4 MB

The following NEW packages will be INSTALLED:

  bzip2              pkgs/main/osx-arm64::bzip2-1.0.8-h80987f9_6 
  ca-certificates    pkgs/main/osx-arm64::ca-certificates-2024.7.2-hca03da5_0 
  libffi             pkgs/main/osx-arm64::libffi-3.4.4-hca03da5_1 
  ncurses            pkgs/main/osx-arm64::ncurses-6.4-h313beb8_0 
  openssl            pkgs/main/osx-arm64::openssl-1.1.1w-h1a28f6b_0 
  pip                pkgs/main/osx-arm64::pip-24.2-py310hca03da5_0 
  python             pkgs/main/osx-arm64::python-3.10.0-hbdb9e5c_5 
  readline           pkgs/main/osx-arm64::readline-8.2-h1a28f6b_0 
  setuptools         pkgs/main/osx-arm64::setuptools-72.1.0-py310hca03da5_0 
  sqlite             pkgs/main/osx-arm64::sqlite-3.45.3-h80987f9_0 
  tk                 pkgs/main/osx-arm64::tk-8.6.14-h6ba3021_0 
  tzdata             pkgs/main/noarch::tzdata-2024a-h04d1e81_0 
  wheel              pkgs/main/osx-arm64::wheel-0.43.0-py310hca03da5_0 
  xz                 pkgs/main/osx-arm64::xz-5.4.6-h80987f9_1 
  zlib               pkgs/main/osx-arm64::zlib-1.2.13-h18a0788_1 


Proceed ([y]/n)? 
## Input: 按下Enter!
## Output: 
Downloading and Extracting Packages:
                                                                                                                                   
Preparing transaction: done                                                                                                        
Verifying transaction: done                                                                                                        
Executing transaction: done                                                                                                        
#
# To activate this environment, use
#
#     $ conda activate iTH-GenAI-Chaos
#
# To deactivate an active environment, use
#
#     $ conda deactivate

這樣一個新的python環境就安裝好,然後我們只要根據以上提示使用conda activate,就能進入我們新的python環境拉~

## Input:
conda activate iTH-GenAI-Chaos

https://ithelp.ithome.com.tw/upload/images/20240925/20151952BjdhE0NHgG.png

安裝環境變數套件:

pip install python-dotenv==1.0.1

安裝jupyter:

pip install jupyter==1.1.1

如果要離開這個環境,回到你原系統使用python的話可以用下面這個指令:

## Input:
conda deactivate

生成式AI開發相關套件安裝

  1. langchain
    pip install langchain langchain_community
    
  2. OpenAI
    pip install openai
    
  3. boto3(AWS)
    pip install boto3
    
  4. Vector store(FAISS) => 向量資料庫
    pip install faiss-cpu
    
  5. LangChain文本處理
    pip install -qU langchain-text-splitters
    
  6. 前端框架 Streamlit
    pip install streamlit
    

上一篇
Day 10 小總結
下一篇
Day12 OpenAI
系列文
生成式 AI之亂—從概念到實踐的LLM開發生態探索12
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言